/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 展示道具
	/// module : structs
	/// </summary>
	public class ItemShowPOD : IPOD 
    {
        public readonly static Func<ItemShowPOD> FACTORY = () => new ItemShowPOD();
		public static Func<ItemShowPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// item配置id
        /// </summary>
		public int cid;
		/// <summary>
        /// 数量
        /// </summary>
		public int num;
		/// <summary>
        /// 
        /// </summary>
		public ItemTag tag;
		
		
		
		/*-- constructors --*/
		public ItemShowPOD() {}
		public ItemShowPOD(int cid, int num, ItemTag tag) {
			this.cid = cid;
			this.num = num;
			this.tag = tag;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(cid);
            _out.Write_int(num);
            _out.Write_byte((sbyte)tag);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            cid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            num = _in.Read_int();
            if(!_in.HasRemaining()) return;
            tag = (ItemTag)_in.Read_byte();
        }
		
		public ItemShowPOD Clone() {
            ItemShowPOD o = DynamicFactory();
            o.cid = cid;
            o.num = num;
            o.tag = tag;
            return o;
        }
        
        public void Clear() {
            cid = default;
            num = default;
            tag = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "ItemShowPOD [";
			str += "cid=";
			str += cid;
			str += ", num=";
			str += num;
			str += ", tag=";
			str += tag;
			str += "]";
			return str;
		}
		
	}
}